﻿using System;
using System.Linq;
using Zeus.Interop.SampleSite.Helpers;
using Zeus.Interop.SampleSite.Stubs;

namespace Zeus.Interop.SampleSite.UserControls
{
    public partial class OrderList : Web.Mvc.Interop.ViewUserControl
    {
        private readonly ICustomerService _customerSvc = ServiceLocator.GetService<ICustomerService>();

        protected void Page_Load(object sender, EventArgs e)
        {
            int customerId = Url.GetCustomerId();

            rp.DataSource = _customerSvc.GetOrdersForCustomer(customerId).SelectMany(order => order.Items);
            rp.DataBind();
        }
    }
}